const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    CustomBar: app.globalData.CustomBar,
    userInfo: null,
    loadModal:false,
    scrollTop: 0,
    scrollTop1: 0,
    curPage: 0,
    cardCur: 0,
    swiperList: [{
      id: 0,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big84000.jpg'
    }, {
      id: 1,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big84001.jpg',
    }, {
      id: 2,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big39000.jpg'
    }, {
      id: 3,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'
    }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  // userInfo 用户信息

  userInfo: function (e) {
    let that = this;
    wx.getUserProfile({
      desc: "请允许权限",
      success: function (res) {
        that.setData({
          loadModal:true,
        });
        // console.log(res);
        let userInfo = res.userInfo;
        wx.login({
          success: function (res1) {
            // console.log(res1);
            let code = res1.code;
            wx.request({
              url: 'https://v.scsongman.cn/api/wxlogin',
              method:"POST",
              data: {
                "userInfo": userInfo,
                "code": code
              },
              success:function(res2){
                if(res2.data.err==0){
                  that.setData({
                    userInfo:res2.data.user_info,
                  })
                }
                that.setData({
                  loadModal:false,
                });
              },
            })
          },
        })
      },
    });
  },

  pageManage: function (e) {
    let that = this;
    let page = e.currentTarget.dataset.page;
    if (!page) {
      page = e.detail.current;
    }
    that.setData({
      curPage: page,
    })
  },

  // cardSwiper
  cardSwiper(e) {
    this.setData({
      cardCur: e.detail.current
    })
  },

  scrolControl: function (e) {
    let scrollTop = e.detail.scrollTop;
    this.setData({
      scrollTop: scrollTop
    })
  },

  scrolControl1: function (e) {
    let scrollTop = e.detail.scrollTop;
    this.setData({
      scrollTop1: scrollTop
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})